package com.java.singleton;

public class ChocolateFactory {
    private boolean empty;
    private boolean boiled;
    static volatile ChocolateFactory uniqueInstance=null;
    
    private ChocolateFactory(){
    	empty=true;
    	boiled=false;
    }
    
    public static ChocolateFactory getInstance(){
   	 if(uniqueInstance==null){
   		 synchronized(ChocolateFactory.class){
   			if(uniqueInstance==null){
   			 uniqueInstance=new ChocolateFactory();
   		    }
   		}
	 }
	 return uniqueInstance;
    } 
    
    public void fill(){
    	if(empty){
    		empty=false;
    		boiled=false;
    	}
    }
    
    public void boil(){
    	if(!(empty&&boiled))boiled=true;
    }
    
    public void drain(){
    	if((!empty)&&boiled)empty=true;
    }
}
